package com.bobohost.crmrbac.web.controller;

import com.bobohost.crmrbac.pojo.po.Permission;
import com.bobohost.crmrbac.pojo.po.QueryObject;
import com.bobohost.crmrbac.service.PermissionService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

/*
 *
 * @author jy
 * @version 1.0
 * @date 2022/2/7 19:13
 */

@Controller
@RequestMapping("/permission")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

//    @RequestMapping("/list")
//    public String list(Model model, @ModelAttribute("qo") QueryObject queryObject){
//        IPage page = Page.of(queryObject.getCurrentPage(), queryObject.getPageSize());
//        IPage< Permission> pageResult = permissionService.findPermissionListPage(page);
//        Map<String, Object> pageInfo = new HashMap<>();
//        pageInfo.put("pageNum", pageResult.getCurrent());
//        pageInfo.put("pages", pageResult.getPages());
//        pageInfo.put("list", pageResult.getRecords());
//        model.addAttribute("pageInfo", pageInfo);
//
//        return "permission/list";
//    }


    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") QueryObject queryObject){
        //调用业务层获取数据
        PageInfo<Permission> pageInfo = permissionService.selectPermissionListPage(queryObject);
        //传到页面
        model.addAttribute("pageInfo",pageInfo);
        //跳转到页面
        return "permission/list";
    }

}
